﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;

namespace ExcelExportLib
{
    /// <summary>Column information</summary>
    [XmlRoot("Column")]
    public class ExcelColumn: IXmlSerializable
    {
        /// <summary>autofit column. Warning: works only if column data is String or DateTime </summary>
        public bool autoFit = true;
        /// <summary>Column width</summary>
        public int width = 20;

        /// <summary>Constructor</summary>
        public ExcelColumn() {}

        /// <summary>Constructor</summary>
        /// <param name="autofit">autofit column. Warning: works only if column data is String or DateTime </param>
        /// <param name="width">Column width</param>
        public ExcelColumn(bool autofit, int width)
        {
            this.autoFit = autofit;
            this.width = width;
        }


        #region IXmlSerializable Members

        public System.Xml.Schema.XmlSchema GetSchema()
        {
            return null;
        }

        public void ReadXml(System.Xml.XmlReader reader)
        {
            throw new NotImplementedException();
        }

        public void WriteXml(System.Xml.XmlWriter writer)
        {
            writer.WriteExcelAttribute("AutoFitWidth", autoFit);
            writer.WriteExcelAttribute("Width", width);
        }

        #endregion
    }
}
